using IQIGame.Onigao.Framework.Serialization;
using System.Collections.Generic;

namespace IQIGame.Onigao.Game
{
    public partial class CFSMStateCfg : ISerializeByteBuf
    {
        public void DeSerialize(ByteBuf _buf)
        {
            id = _buf.ReadInt();
            name = _buf.ReadString();
            conditions = _buf.DeSerializeListInt();
            int count = _buf.ReadInt();
            customParams = new List<NamedParam>(count);
            for (int i = 0; i < count; i++)
            {
                NamedParam p = new NamedParam();
                p.DeSerialize(_buf);
                customParams.Add(p);
            }
        }

        public void Serialize(ByteBuf _buf)
        {
            _buf.WriteInt(id);
            _buf.WriteString(name);
            _buf.SerializeListInt(conditions);
            _buf.WriteInt(customParams.Count);
            for (int i = 0; i < customParams.Count; i++)
            {
                NamedParam p = customParams[i];
                p.Serialize(_buf);
            }
        }
    }
}